package main.com.hjy.jdbc.controller;

import main.com.hjy.jdbc.entity.RoomInfo;
import main.com.hjy.jdbc.service.RoomInfoService;
import main.com.hjy.jdbc.service.impl.RoomInfoServiceImpl;

import java.util.List;

public class RoomInfoController {

public boolean addRoomInfo(RoomInfo roominfo)
{
    RoomInfoService roomInfoService = new RoomInfoServiceImpl();
    boolean bl= roomInfoService.addRoomInfo(roominfo);
    if(bl)
    {
        return true;
    }
    else
    {
        return false;
    }
  }


    public boolean deleteRoomInfo(RoomInfo roominfo)
    {
        RoomInfoService roomInfoService = new RoomInfoServiceImpl();
        boolean bl= roomInfoService.deleteRoomInfo(roominfo);
        if(bl)
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    public List<RoomInfo> queryAllRoomInfo()
{
    RoomInfoService roomInfoService = new RoomInfoServiceImpl();
    List<RoomInfo> roomInfoList = roomInfoService.queryAllRoomInfo();
    if(roomInfoList!=null) {
        if (roomInfoList.size() > 0) {
            return roomInfoList;
        } else {
            return null;
        }
    }
    return roomInfoList;
}

public boolean updateRoomInfo(String roomid,String roomname,String roomtypeid,Double price,Integer status,Integer capacity)
{
    RoomInfoService roomInfoService = new RoomInfoServiceImpl();
    boolean bl=roomInfoService.updateRoomInfo(String roomid,String roomname,String roomtypeid,Double price,Integer status,Integer capacity);
    if(bl)
    {
        return true;
    }
    else
    {
        return false;
    }
}





//
//    public List<Emp> queryAllEmp() {
//        Emp2Service emp2Service = new Emp2ServiceImpl();
//        List<Emp> empList = emp2Service.queryAllEmp();
//        if (empList != null) {
//            if (empList.size() > 0) {
//                return empList;
//            }
//
//        } else {
//            return null;
//        }
//        return null;
//
//    }
















  public static void main(String[] args) {
    RoomInfoController roomInfoController = new RoomInfoController();
    RoomInfo roominfo = new RoomInfo();

    roominfo.setRoomid("A201");
    roominfo.setRoomname("海景大床房");
    roominfo.setRoomtypeid("Single Room");
    roominfo.setPrice(200.00);
    roominfo.setStatus(1);
    roominfo.setCapacity(2);
    boolean bl = roomInfoController.addRoomInfo(roominfo);
    if(bl)
    {
        System.out.println(roominfo);
    }
    else
    {
        System.out.println("添加失败!");
    }

  }




}



